﻿Imports System
Imports System.IO
Imports System.Data
Imports System.Data.SqlServerCe
Imports System.Drawing
Imports System.Collections
Imports System.Windows.Forms
Imports System.Data.Common

Module HeatNumberDao

    Public Function findHeatNos(ByVal projectId As String, ByVal heatName As String) As DataTable
        Dim dtResult As New DataTable
        Dim paramList As New Hashtable()

        Dim SQL As String = "SELECT * FROM eqam_heat_number WHERE 1=1 "

        If (projectId IsNot Nothing And projectId <> "") Then
            SQL = SQL & " AND PROJECT_ID = @PROJECT_ID"
            paramList.Add("@PROJECT_ID", projectId)
        End If

        If (heatName IsNot Nothing And heatName <> "") Then
            SQL = SQL & " AND HEAT_NUMBER_NAME = @HEAT_NUMBER_NAME"
            paramList.Add("@HEAT_NUMBER_NAME", heatName)
        End If

        SQL = SQL & " ORDER BY HEAT_NUMBER_NAME "

        Return LoadData(SQL, paramList)
    End Function

    Public Function fetchHeatNumberByWeldSizeJointType(ByVal projectId As String, ByVal weldSize As String, ByVal jointType As String) As String
        Dim dtResult As New DataTable
        Dim paramList As New Hashtable()
        Dim result As String = ""

        Dim SQL As String = "SELECT HEAT_NUMBER_NAME FROM eqam_heat_number WHERE PROJECT_ID = @PROJECT_ID"

        paramList.Add("@PROJECT_ID", projectId)

        dtResult = LoadData(SQL, paramList)
        If dtResult.Rows.Count > 0 Then
            result = dtResult.Rows(0).Item("HEAT_NUMBER_NAME")
        End If

        Return result
    End Function

End Module
